#pragma once

#ifdef _DEBUG
#include <iostream>
using std::wcout;
using std::endl;
#endif
#include "Timer.h"
#include "PluginLoader.h"

namespace SubPlayer
{
    class SubtitleHandler
    {
    public:
        SubtitleHandler( const wstring &dllPath, const wstring &encoding, HWND hWnd);
        ~SubtitleHandler();
        int LoadSubtitles();
        inline wstring GetSubtitlePath() const {return subtitlePath;}
        wstring GetLastError() const {return lastError;}
        void SetEncoding(const wstring &encoding) {usedEncoding = encoding;} // TODO: encoding should be some enum or maybe function pointer, becouse there are only 3 accepted values. wstring is just teporary
        inline long getSubEndTime() {return plugin.GetEndTime();}
        void StartPlaying();
        inline wstring GetCurrentSub() const {return currentSub;}
        // TODO: malo by zacat posielat spravy a zobrazovat titulky. Takze asi spravit nejaky timer a bud posielat priamo jeho spravy, alebo nejake vlastne
        //v messageCallback sa akurat zavola pri stisku nejakej klavesy start a potom uz bude tento modul posielat spravy sam.
        wstring test();
        static VOID CALLBACK TimerProc_Wrapper(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime);
    private:
        int OpenSubFile(wstring& subtitlePath);
        VOID CALLBACK TimerEvent(_In_ HWND hwnd, _In_ UINT, _In_ UINT_PTR idEvent, _In_ DWORD dwTime);

        static void * pObject;
        PluginLoader plugin;
        wstring subtitlePath;
        wstring lastError;
        wstring usedEncoding;
        wstring currentSub;
        Timer timer;
        HWND hWnd;
    };
}
